import Route from 'react-router/lib/Route';
import { WeaErrorPage, WeaLocaleProvider } from 'ecCom';
import { Provider } from 'mobx-react';

import { IndexRedirect } from 'react-router';
import Home from './components/Home';
import Cowork from './components/cowork/';
import Collect from './components/Collect'; // 收藏的帖子
import Mine from './components/Mine'; // 我的帖子
import ItemApproval from './components/ItemApproval'; // 主题审批
import ItemMonitor from './components/ItemMonitor'; // 主题监控
import Apply from './components/Apply'; // 协作申请
import RelateMe from './components/RelateMe'; // 协作申请
import DiscussApproval from './components/DiscussApproval'; // 内容审批
import DiscussMonitor from './components/DiscussMonitor'; // 内容监控
import CommentMonitor from './components/CommentMonitor'; // 评论监控
import Hrmview from './components/Hrmview'; // 参与的协作
import NewCowork from './components/cowork/dialog/NewCowork';
 // 新建协作
const getLabel = WeaLocaleProvider.getLabel;

import './style/index';
import stores from './stores/index';

const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'cowork');
const { getLocaleLabelByCode } = WeaLocaleProvider;

class Error extends React.Component {
  render() {
    return (
      <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@jmauio`} msg={getLabel(193, '对不起，无法找到该页面！', 'error')} />
    );
  }
}
const coworkRoute = (
  <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@p1wrbm`} path="cowork" onEnter={getLocaleLabel} component={Home}>
    <IndexRedirect ecId={`${this && this.props && this.props.ecId || ''}_IndexRedirect@bdz3jk`} to="main" />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@biz0et`} path="main" component={Cowork}>
      <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@r22uop`} path=":coworkId">
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@tjx3hk`} path=":floorNum" />
        </Route>
      </Route>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@1maht8`} path="collect" component={Collect} />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@bqboxu`} path="relateMe" component={RelateMe} />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@5w0zck`} path="mine" component={Mine} />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@1mebrr`} path="itemApproval" component={ItemApproval} />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@v7dhhk`} path="itemMonitor" component={ItemMonitor} />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@x0s6js`} path="apply" component={Apply} />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@nl7ken`} path="discussApproval" component={DiscussApproval} />
	  <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@u1ptyy`} path="discussMonitor" component={DiscussMonitor} />
	  <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@26xjsy`} path="commentMonitor" component={CommentMonitor} />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@jyaa3p`} path="hrmview" component={Hrmview} />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@t4fzpa`} path="*" component={Error} />
  </Route>
);

class CreateCowork extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      reRender: false,
    };
  }
  componentDidMount() {
    getLocaleLabelByCode('cowork').then(() => this.setState({ reRender: true }));
  }

  render() {
    return <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@z4o8js`} {...stores}><NewCowork ecId={`${this && this.props && this.props.ecId || ''}_NewCowork@8gye5e`} {...this.props} storeMapKey={3} /></Provider>;
  }
}

module.exports = {
  Route: coworkRoute,
  store: stores,
  com: {
    CreateCowork,
  },
};
